package biz.bbtec.sbm.mytask.action;
import java.text.ParseException;
import java.util.Calendar;
import java.util.Date;
import java.util.Timer;
import java.util.TimerTask;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import biz.bbtec.sbm.email.action.EmailAlarmAction;
import biz.bbtec.sbm.user.bean.UserBean;

/**
 * @date 2014-02-22
 * @author chenxu
 *
 */

public class MyTask {
	private static final Log log = LogFactory.getLog(MyTask.class);
	 private static boolean isRunning = false;
	 EmailAlarmAction ea;
	Timer timer;
	public MyTask(){
		timer=new Timer();
		timer.schedule(new MyTimerTask(), 0,3600000);
	}

	class MyTimerTask extends TimerTask{
		public void run(){
			log.info("---------------定时器开始-----------------");
			if(!isRunning){
				 isRunning = true;	
				 Date date=new Date();
					int hour=date.getHours();
					 ea=new EmailAlarmAction();			
					 try {
						String flag=ea.TimingEmailSend();						
						 log.info("--------邮件已发送--------");
					} catch (ParseException e1) {
						// TODO Auto-generated catch block
						e1.printStackTrace();
					}
					 isRunning= false;
			}else{
				log.info("-------还在执行中---------");
			}
			log.info("---------定时器结束--------");
			 
			
		}
	}
}
